/*
@	Name: Cash item Gachapon
	AcarsiaSEA
 */

var status = -1;

function action(mode, type, selection) {
    if (mode == 1) {
	status++;
    } else {
	status--;
    }
    if (status == 0) {
	if (cm.haveItem(4000188)) {
	    cm.sendYesNo("You have some #bDuck Eggs#k there.\r\nWould you like to redeem for cash items?");
	} else {
	    cm.sendOk("You don't have any Duck Eggs with you. Please Vote to get the Duck Eggs before coming back to me. Thank you.");
	    cm.safeDispose();
	}
    } else if (status == 1) {
	var item;
	if (Math.floor(Math.random() * 70) == 0) {
	    var rareList = new Array(1002575);

	    item = cm.gainGachaponItem(rareList[Math.floor(Math.random() * rareList.length)], 1);
	} else {
	    var itemList = new Array(1702143, 1702174, 1702050, 1702072, 1702079, 1702080, 1702081, 1702084, 1702085, 1702086, 1702087, 1702180, 1702181, 1702183, 1702184, 1702179, 1702189, 1702191, 1702192, 1702193, 1702194, 1102087, 1102091, 1102092, 1102087, 1102093, 1102094, 1102095, 1102096, 1102097, 1102098, 1102110, 1102111, 1102112, 1102108, 1102141, 1102072, 1102073, 1102074, 1102075, 1102076, 1102175, 1102154, 1102155, 1102156, 1072336, 1072337, 1072338, 1072407, 1072417, 1072418, 1072257, 1072258, 1072259, 1082162, 1082170, 1082171, 1082172, 1082173, 1082227, 1082226, 1082225, 1102157, 1102158, 1102067, 1102068, 1102069, 1102070, 1022044, 1022043, 1062047, 1062048, 1062049, 1042048, 1002343, 1002344, 1002345, 1002346, 1002347, 1062050, 1062051, 1062052, 1062053, 1061067, 1062055, 1062056, 1062056, 1062057, 1062112, 1062113, 1062114, 1062115, 1062116, 1012080, 1012081, 1012082, 1012083, 1012084, 1702208, 1702211, 1072187, 1072188, 1072189, 1072190, 1072332, 1072333, 1072334, 1072335, 1072336, 1072337, 1072338, 1072348, 1702212, 1702213, 1702218, 1072349, 1072350, 1702226, 1702227, 1702228, 1702229, 1702229, 1702253, 1702252, 1702145, 1702146, 1702147, 1702144, 1702148, 1002575, 1002258, 1002536, 1002524, 1002523, 1002522, 1002525, 1002526, 1042129, 1042130, 1042131, 1042132, 1042101, 1042102, 1042103, 1042104, 1042105, 1042022, 1042023, 1042025, 1042026, 1042155, 1042156, 1042157, 1042158, 1042070, 1042071, 1042072, 1042073, 1042074, 1042075, 1042076, 1042077, 1042078, 1040119, 1042045, 1042046, 1042047, 1042048, 1002738, 1002737, 1002736, 1002735, 1002978, 1002977, 1002976, 1002975, 1003022, 1003016, 1003015, 1002576, 1002577, 1002578, 1002579, 1002675, 1002676, 1002677, 1002678, 1002679, 1002849, 1802046, 1000026, 1002592, 10025910, 1012208, 01022033, 01003221, 01003222, 01003220, 01042142, 01042125, 01042150, 01042127, 01042188, 01052142, 01072507, 01072517, 01082253, 01082251, 01082229, 01102285, 01102286, 01102287, 01102325, 01102326, 01702329, 01702330, 01702331, 01702332, 01702333, 01702334, 01702335,
 01702336, 01702337, 01702352, 01702358, 01702352, 01702350, 01002426, 01002427, 01002429, 01002449, 01002450, 01002451, 01002567, 01002568, 01002709, 01002715, 01002950, 01002884, 01002885, 01002886, 01002887, 01002888, 01002889, 01003057, 01003058, 01003059, 01003060, 01003263, 01003264, 01003265, 01003268, 01003269, 01003270, 01003271, 01702266, 01702267, 01702268, 01702269, 01702270, 01702271, 01702272, 01702273, 01702274, 01702275, 01702276, 01702277, 01102060, 01102061, 01102062, 01102063, 01102064, 01102065, 01042160, 01042161, 01042162, 01042163, 01042164, 01042165, 01042166, 01042167, 01042168, 01042169, 01042176, 01042177, 01042178, 01042169, 01042170, 01042171, 01042172, 01042173, 01042174, 01042149, 01051129, 01051130, 01051131, 01051132, 01051133, 01051134, 01051135, 01051136, 01051137, 01051138, 01051139, 01002225, 01041142, 01041130, 01041129, 01041113, 01042222, 01042202, 01042198, 01042199, 01042200, 01061001, 01061007, 01062139, 01072507, 01702119, 01702118, 01702115, 01702136, 01702142,
 01702155, 1092056, 1012057, 1003271, 1003276, 1082227, 1082102, 1702224, 1702099, 1032024, 1102039, 1022079);
	    item = cm.gainGachaponItem(itemList[Math.floor(Math.random() * itemList.length)], 1);
	}
	if (item != -1) {
	    cm.gainItem(4000188, -1);
	    cm.sendOk("You have obtained #b#t" + item + "##k.");
	} else {
	    cm.sendOk("Please check your item inventory and see if you have any Eggs, or if the inventory is full.");
	}
	cm.safeDispose();
    }
}